clc  
img = imread('matlab_trial2.jpeg'); 
subplot(2,2,1),imshow(img);
imshow(img); 
FaceDetect = vision.CascadeObjectDetector; 
FaceDetect.MergeThreshold = 7 ;
BB = step(FaceDetect, img); 
subplot(2,2,2),imshow(img); 
for i = 1 : size(BB,1)     
  rectangle('Position', BB(i,:), 'LineWidth', 3, 'LineStyle', '-', 'EdgeColor', 'b'); 
end 
for i = 1 : size(BB, 1) 
  J = imcrop(img, BB(i, :));
  subplot(2,1,2),imshow(J); 
end